package com.suoluo.zenadmin.service;



public class UpgradeServiceImpl implements UpgradeService{

//	@Autowired
//	private UpgradeDAO upgradeDAO;
//	
//	@Autowired
//	private TripDAO tripDAO;
//	@Override
//	public void updateUpgradeTrip() {
//		List<TripPOJO> trips = upgradeDAO.findTrips();
//		int count = tripDAO.findTripCount();
//		if (count > 0){
//			return;
//		}
//		for (TripPOJO bt : trips){
//			TripVO trip = new TripVO();
//			trip.setBookUrl(null);
//			trip.setDays(bt.getTripDays());
//			trip.setDepartureCity(null);
//			trip.setDepartureDate(null);
//			trip.setDistance(bt.getTripDistance().intValue());
//			trip.setImage(bt.getTripOrigImg());
//			trip.setName(bt.getTripName());
//			trip.setPrice(0);
//			//升级完成的行程设置为编辑中
//			trip.setStatus(SystemType.TRIP_STATUS_EIDT);
//			trip.setSummary(null);
////			trip.setTripId(tripId)
//			int tripId = tripDAO.addTrip(trip);
//			trip.setTripId(tripId);
//			
//			//同步目的地
//			updateTripDest(trip,bt.getTripId());
//			
//			//同步行程的天记录
//			updateTripDaily(trip,bt.getTripId());
//		}
//	}
//	
//	private void updateTripDest(TripVO trip,int oldTripId){
//		List<TripDestPOJO> dests = upgradeDAO.findTripDests(oldTripId);
//		for (TripDestPOJO dp : dests){
//			TripTripdestsVO ttd = new TripTripdestsVO();
//			ttd.setDestId(dp.getDestId());
//			ttd.setDestName(dp.getDestName());
//			ttd.setTripId(trip.getTripId());
//			TripdestVO tripdest = tripDAO.findTripdestByDestId(dp.getDestId());
//			ttd.setTripdestId(tripdest.getTripdestId());
//			tripDAO.addTripTripdest(ttd);
//		}
//		
//	}
//	
//	private void updateTripDaily(TripVO trip,int oldTripId){
//		List<TripDaysVO> tripDays = upgradeDAO.findTripDays(oldTripId);
//		
//		int dayNo = 0;
//		for (TripDaysVO day : tripDays){
//			TripDailyVO dy = new TripDailyVO();
//			dy.setBreakfast(null);
//			dy.setContent(StringUtil.substring(day.getTripDayDesc(), 1024, null));
//			dy.setDailyNo(++dayNo);
//			dy.setHotel(null);
//			dy.setLunch(null);
//			dy.setSupper(null);
//			dy.setTripId(trip.getTripId());
//			
//			int dailyId = tripDAO.addTripDaily(dy);
//			dy.setDailyId(dailyId);
//			
//			//同步每天下的地点信息
//			updateTripDailyLocations(trip, day, dy);
//		}
//	}
//	
//	private void updateTripDailyLocations(TripVO trip,TripDaysVO tripDay,TripDailyVO daily){
//		List<TripItemPOJO> dayItems = upgradeDAO.findTripDayItems(tripDay.getTripDayId());
////		List<TripDailyLocationsVO> locs = new ArrayList<TripDailyLocationsVO>();
//		int locNo = 0;
//		for (TripItemPOJO item : dayItems){
//			TripDailyLocationsVO dl = new TripDailyLocationsVO();
//			dl.setDailyId(daily.getDailyId());
//			TripLocationVO loc = tripDAO.findTripLocationByDataId(item.getRelId());
//			if(loc == null) {
//				continue;
//			}
//			dl.setLocationId(loc.getLocationId());
//			dl.setLocationName(item.getTripItemTitle());
//			dl.setLocationNo(++locNo);
//			dl.setTripdestId(loc.getTripdestId());
//			dl.setTripId(trip.getTripId());
//			tripDAO.addTripDailyLocation(dl);
//		}
//	}
}
